package com.shaliy.collector.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import com.shaliy.collector.entity.UserEntity;
import com.shaliy.collector.repository.UserRepository;
import com.shaliy.collector.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Resource
	private UserRepository userRepository;
	
	@Override
	public UserEntity findOne(String phone) {
		UserEntity u = new UserEntity();
		u.setPhone(phone);
		return userRepository.findOne(Example.of(u)).get();
	}

	public UserEntity save(String phone,String username,String password) {
		UserEntity u = new UserEntity();
		u.setPhone(phone);
		u.setPassword(password);
		u.setCreateTime(new Date());
		u.setUpdateTime(new Date());
		u.setUsername(username);
		return userRepository.save(u);
	}
}
